/*****************************************************************************
 * decoder.h
 *
 * Copyright (C) 2020 Jeasonvor 1101627719@qq.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/
#ifndef __DECODER_H__
#define __DECODER_H__

/*****************************************************************************
 * Included Files
 ****************************************************************************/

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

/*****************************************************************************
 * Public Types
 ****************************************************************************/

typedef struct {
    unsigned int pin_a0;
    unsigned int pin_a1;
    unsigned int pin_a2;
} dev_decoder_pin_t;

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/*
 * @brief:  解码器初始化
 *
 * @param[in]:  pin     -   解码器组引脚
 * @param[in]:  cnt     -   解码器数量
 *
 * @return:
 **/
int dev_decoder_init(dev_decoder_pin_t pin[], int cnt);

/*
 * @brief:  写解码器数据
 *
 * @param[in]:  idx     -   解码器组索引（以0为起点）
 * @param[in]:  code    -   待解码数据([bit7 ~ bit0] : Y7 ~ Y0)
 *
 * @return:
 **/
int dev_decoder_write(int idx, unsigned char code);

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __DECODER_H__ */
/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
